package jh.com.jhappbf.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;

public class MyHorizontalView extends HorizontalScrollView {

    public MyHorizontalView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	private int startX;
    private int startY;

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			startX = (int) ev.getX();
			startY = (int) ev.getY();
			break;
		case MotionEvent.ACTION_MOVE:
			int dx = (int) (ev.getX() - startX);
			int dy = (int) (ev.getY() - startY);
			return Math.abs(dx) > Math.abs(dy);
		case MotionEvent.ACTION_CANCEL:
			break;
		default:
			break;
		}
		return super.onInterceptTouchEvent(ev);
	}
}
